package com.cy.pj.brand.service.impl;

import com.cy.pj.brand.dao.BrandDao;
import com.cy.pj.brand.pojo.Brand;
import com.cy.pj.brand.service.BrandService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {
    private static final Logger log=
            LoggerFactory.getLogger(BrandServiceImpl.class);
    @Autowired
    private BrandDao brandDao;

    //查询
    @Override
    public List<Brand> findBrands(String name) {
        long t1=System.currentTimeMillis();
        List<Brand> list=brandDao.findBrands(name);
        long t2=System.currentTimeMillis();
        log.info("select time:{}",t2-t1);//这里的{}表示占位符
        return list;
    }

    //删除
    @Override
    public int deleteById(Integer id) {
        long t1=System.currentTimeMillis();
        int rows=brandDao.deleteById(id);
        long t2=System.currentTimeMillis();
        log.info("delete time:{}",t2-t1);
        return rows;
    }

    //新增
    @Override
    public int insertBrand(Brand entity) {
        long t1=System.currentTimeMillis();
        int rows=brandDao.insertBrand(entity);
        long t2=System.currentTimeMillis();
        log.info("delete time:{}",t2-t1);
        return rows;
    }

    //根据id修改
    @Override
    public Brand findByIds(Integer id) {
        return brandDao.findByIds(id);
    }

    @Override
    public int updateBrand(Brand brand) {
        return brandDao.updateBrand(brand);
    }

}
